
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>新零售商城后台首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
				<div class="layui-inline" style="float:right">
					<button class="layui-btn layuiadmin-btn-admin" data-type="add" onclick="WinOpenAdd();">添加</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table class="layui-hide" id="test"></table>

            <script type="text/html" id="barDemo">
                <a class="layui-btn layui-btn-xs" lay-event="edit" onclick="WinOpenEdit({{d.userId}})" >编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="WinOpenDel({{d.userId}})">删除</a>
            </script>

        </div>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script type="text/javascript" src="/shoppingApi/js/jquery-3.3.1.min.js"></script>
<script type="application/javascript" src="/shoppingApi/js/common.js"></script>
<!--<script th:src="@{/js/user/layuiuser.js}"></script>-->
<style>
    .layui-body{overflow-y: scroll;}
</style>
<script>
    var table;
    layui.use('table', function(){
        table = layui.table
            ,form = layui.form;

        table.render({
            elem: '#test'
            ,url:'/data/user/rank.js'
            ,cellMinWidth: 80
            ,cols: [[
                {type:'numbers'}
                ,{type: 'checkbox'}
                ,{field:'rankid', title:'ID'}
				,{field:'rankname', title:'等级名称'}
				,{field:'commission', title: '店主节省'}
				,{field:'sort', title: '排序'}
				,{field:'rankid', title:'编辑', minWidth:180, templet: '#barDemo', unresize: true}
            ]]
            ,id: 'testReload'
        });

        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });


    });





    function createTime(v){
        return new Date(parseInt(v)).toLocaleString()
    }
    /**重写toLocaleString方法*/
    Date.prototype.toLocaleString = function() {
        var y = this.getFullYear();
        var m = this.getMonth()+1;
        m = m<10?'0'+m:m;
        var d = this.getDate();
        d = d<10?("0"+d):d;
        var h = this.getHours();
        h = h<10?("0"+h):h;
        var M = this.getMinutes();
        M = M<10?("0"+M):M;
        var S=this.getSeconds();
        S=S<10?("0"+S):S;
        return y+"-"+m+"-"+d+" "+h+":"+M+":"+S;}


    /*添加*/
	function WinOpenAdd(){
		window.parent.WinOpenAdd(this,"/user/rank/add.html","添加",330,300,1);
	}	
	
	/*编辑*/
	function WinOpenEdit(categoryId){
		window.parent.WinOpenEdit(this,"/user/rank/edit.html?categoryId="+categoryId,"修改资料",330,300,1);
	}
	
	/*删除*/
	function WinOpenDel(categoryId){
		window.parent.WinOpenEdit(this,"/user/rank/del.html?categoryId="+categoryId,"删除",340,300,1);
	}
	
</script>


</body>
</html>